package cn.edu.zafu.bigdata.cdn;

public class Cube {
    private double length;
    private double width;
    private double height;
    public Cube(double length, double width, double height) {
        this.length = length;
        this.width = width;
        this.height = height;
    }
    public double getLength() {
        return length;
    }
    public double getWidth() {
        return width;
    }
    public double getHeight() {
        return height;
    }
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }

        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }

        Cube cube = (Cube) obj;

        return Double.compare(cube.length, length) == 0 &&
                Double.compare(cube.width, width) == 0 &&
                Double.compare(cube.height, height) == 0;
    }
    public static void main(String[] args) {
        Cube cube1 = new Cube(3.0, 3.0, 3.0);
        Cube cube2 = new Cube(3.0, 3.0, 3.0);
        Cube cube3 = new Cube(4.0, 4.0, 4.0);
        Cube cube4 = new Cube(3.0, 4.0, 3.0);

        System.out.println("cube1 equals cube2: " + cube1.equals(cube2)); // 应该返回true
        System.out.println("cube1 equals cube3: " + cube1.equals(cube3)); // 应该返回false
        System.out.println("cube1 equals cube4: " + cube1.equals(cube4)); // 应该返回false
    }
}